import request from '@/utils/request';

/*************************************项目管理********************************/
/**
 * 查询项目信息列表
 */
export const listProject = (query: any) => {
  return request({
    url: '/project/list',
    method: 'get',
    params: query,
  });
};

/**
 * 查询项目信息详细
 */
export const getProject = (projectId: any) => {
  return request({
    url: `/project/${projectId}`,
    method: 'get',
  });
};

/**
 * 新增项目信息
 */
export const addProject = (data: any) => {
  return request({
    url: '/project',
    method: 'post',
    data: data,
  });
};

/**
 * 修改项目信息
 */
export const updateProject = (data: any) => {
  return request({
    url: '/project',
    method: 'put',
    data: data,
  });
};

/**
 * 删除项目信息
 */
export const delProject = (projectId: any) => {
  return request({
    url: `/project/${projectId}`,
    method: 'delete',
  });
};

/**
 * 获取项目树
 */
export const getProjectData = (params?: any) => {
  return request({
    url: '/project/treeselect',
    method: 'get',
    params,
  });
};

/*************************************预警等级配置********************************/
/**
 * 查询设备管理列表
 */
export const listLevelWarm = (query: any) => {
  return request({
    url: '/levelConfig/list',
    method: 'get',
    params: query,
  });
};

/**
 * 修改
 */
export const updateWarm = (data: any) => {
  return request({
    url: '/levelConfig',
    method: 'put',
    data: data,
  });
};

/**
 * 新增
 */
export const addWarm = (data: any) => {
  return request({
    url: '/levelConfig',
    method: 'post',
    data: data,
  });
};

/**
 * 删除
 */
export const deleteWarm = (name: any) => {
  return request({
    url: `/levelConfig/${name}`,
    method: 'delete',
  });
};

/**
 * 查询省份
 */
export const getProvinceList = () => {
  return request({
    url: '/chinaArea/getProvinceList',
    method: 'get',
  });
};

/*************************************消息推送配置********************************/
/**
 * 查询微信推送配置
 */
export const getWxMessageList = () => {
  return request({
    url: '/wxmessage/config',
    method: 'get',
  });
};

/**
 * 修改单条微信推送配置
 */
export const putWxMessage = (data: any) => {
  return request({
    url: '/wxmessage/config',
    method: 'put',
    data: data,
  });
};

/**
 * 测试单条微信推送配置
 */
export const TestWxMessage = () => {
  return request({
    url: '/wxmessage/config/test',
    method: 'get',
  });
};

/*************************************升级包配置********************************/
/**
 * 获取升级信息列表
 * @param {any} data - 包含查询条件的对象
 * @returns {Promise} - 返回一个 Promise，用于处理异步请求的结果
 */
export const getUpgradeList = (data: any) => {
  return request({
    url: '/deviceUpgrade/list',
    method: 'post',
    data,
  });
};

/**
 * 保存或更新升级信息
 * @param {any} data - 包含升级信息的对象
 * @returns {Promise} - 返回一个 Promise，用于处理异步请求的结果
 */
export const upgradeInfo = (data: any) => {
  return request({
    url: '/deviceUpgrade/save',
    method: 'post',
    data,
  });
};

/**
 * 删除升级信息
 * @param {any} id - 升级信息的唯一标识符
 * @returns {Promise} - 返回一个 Promise，用于处理异步请求的结果
 */
export const deleteUpgrade = (id: any) => {
  return request({
    url: '/deviceUpgrade/delete/' + id,
    method: 'post',
  });
};

/**
 * 获取设备模型树数据
 * @returns {Promise} - 返回一个 Promise，用于处理异步请求的结果
 */
export const modelTree = () => {
  return request({
    url: '/deviceMode/device/modelPull',
    method: 'get',
  });
};

/**
 * 根据设备ID获取当前版本信息
 * @param {any} ids - 设备ID或ID数组
 * @returns {Promise} - 返回一个Promise，用于处理异步请求的结果
 */
export const getCurrentVersion = (ids: any) => {
  return request({
    url: '/deviceUpgrade/currentVersion/' + ids,
    method: 'get',
  });
};

/**
 * 获取升级信息详情
 * @param {any} id - 升级信息的唯一标识符
 * @returns {Promise} - 返回一个 Promise，用于处理异步请求的结果
 */
export const getUpgradeDetail = (id: any) => {
  return request({
    url: '/deviceUpgrade/detail/' + id,
    method: 'get',
  });
};

/**
 * 获取特定设备的当前版本类型信息
 * @param {any} id - 设备的唯一标识符
 * @returns {Promise} - 返回一个 Promise，用于处理异步请求的结果
 */
export const currentVersionType = (id: any) => {
  return request({
    url: '/deviceUpgrade/currentVersionType/' + id,
    method: 'get',
  });
};

/**
 * 提交设备升级包的审核请求
 * @param {any} data - 包含审核信息的对象
 * @returns {Promise} - 返回一个 Promise，用于处理异步请求的结果
 */
export const packageAudit = (data: any) => {
  return request({
    url: '/deviceUpgrade/submitAudit',
    method: 'post',
    data,
  });
};

/**
 * 获取升级包信息下拉列表
 * @returns {Promise} - 返回一个 Promise，用于处理异步请求的结果
 */
export const pullPackageList = (params: any) => {
  return request({
    url: '/deviceUpgrade/pullList',
    method: 'get',
    params,
  });
};

/**
 * 查询省份下所有城市
 */
export function getCityByProvince(params: any) {
  return request({
    url: 'centerStationInfo/getCityByProvince',
    method: 'GET',
    params,
  });
}
/**
 * 查询城市下所有乡镇
 */
export function getAreaByCity(params: any) {
  return request({
    url: 'centerStationInfo/getAreaByCity',
    method: 'GET',
    params,
  });
}

// 新增项目
export function addProjectNew(data: any) {
  return request({
    url: `/project/addProjectNew`,
    method: 'POST',
    data,
  });
}

// 新增目录
export function addCatalogueNew(data: any) {
  return request({
    url: `/project/addCatalogueNew`,
    method: 'POST',
    data,
  });
}

// 审核
export function getProjectPass(id: any) {
  return request({
    url: `/project/projectPass/${id}`,
    method: 'POST',
  });
}

// 修改
export function editProject(data: any) {
  return request({
    url: `/project/project/edit`,
    method: 'POST',
    data,
  });
}

// 查询
export function getListNew(params: any) {
  return request({
    url: `/project/listNew`,
    method: 'get',
    params,
  });
}

// 查询详情
export function getDetailNew(id: any) {
  return request({
    url: `/project/detailNew/${id}`,
    method: 'get',
  });
}

// 查询省市区
export function getChinaArea(params?: any) {
  return request({
    url: `/util/getChinaarea`,
    method: 'get',
    params,
  });
}

// 设置为测试项目
export function setTestProject(data: any) {
  return request({
    url: `/project/setTestProject`,
    method: 'post',
    data,
  });
}

// 删除项目
export function removeNewProject(id: any) {
  return request({
    url: `/project/removeNew/${id}`,
    method: 'delete',
  });
}

// 重命名
export function updateCatalogueNew(data: any) {
  return request({
    url: `/project/updateCatalogueNew`,
    method: 'post',
    data,
  });
}

// 修改目录编码
export function updateCatalogueCode(data: any) {
  return request({
    url: `/project/updateCatalogueCode`,
    method: 'post',
    data,
  });
}

// 修改目录信息
export function updateProjectDataInfo(data: any) {
  return request({
    url: `/project/updateProjectDataInfo`,
    method: 'post',
    data,
  });
}
